package com.bangdream.michelia.utils;

/**
 * Created by Mr.Wang on 2017/11/30.
 * 909732184@qq.com
 * 文本后缀处理工具类
 */

public class SuffixUtil {
    private static final String TAG = "SuffixUtil";

    //文档大致类型 图片 word xlsx pdf 文本 ppt
    public enum FileType{
        PICTURE,WORD,XLSX,PDF,TXT,PPT,UNKNOWN
    }
    //用后缀名转换成大致文档类型
    public static FileType SuffixToType(String suffix){
        MyLog.d(TAG,"传入的后缀为："+suffix);
        if(suffix!=null){
            if(suffix.contains("jpg") ||suffix.contains("jpeg") ||suffix.contains("png")||suffix.contains("bmp")
                    ||suffix.contains("JPG") ||suffix.contains("JPEG") ||suffix.contains("PNG")||suffix.contains("BMP")){
                return FileType.PICTURE;
            }
            else if(suffix.contains("doc") ||suffix.contains("docx") ||suffix.contains("DOC")||suffix.contains("DOCX")){
                return FileType.WORD;
            }
            else if(suffix.contains("pdf") ||suffix.contains("PDF")){
                return FileType.PDF;
            }
            else if(suffix.contains("xls") ||suffix.contains("xlsx")||suffix.contains("XLS") ||suffix.contains("XLSX")){
                return FileType.XLSX;
            }
            else if(suffix.contains("ppt") ||suffix.contains("pptx")||suffix.contains("PPT") ||suffix.contains("PPTX")){
                return FileType.PPT;
            }
            else if(suffix.contains("txt") ||suffix.contains("TXT")){
                return FileType.TXT;
            }
            else {
                return FileType.UNKNOWN;
            }
        }else {
            return FileType.UNKNOWN;
        }
    }
}
